package com.emser.unc.server.domain;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.emser.unc.serializable.SellerDTO;
import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;

@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable = "true")
public class Seller {
	@PrimaryKey
	private Key key;
	@Persistent
	private String userName;
	@Persistent
	private String password;
	@Persistent
	private String firstName;
	@Persistent
	private String lastName;
	@Persistent
	private String telephone;
	@Persistent
	private String address;
	@Persistent
	private String city;
	@Persistent
	private String zipCode;
	@Persistent
	private String serialDevice;
	@Persistent
	private Long versionCustomer;
	@Persistent
	private Long versionProduct;
	@Persistent
	private UserAccount userA;
	
	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		Key k = KeyFactory.createKey(Seller.class.getSimpleName(), userName);
		this.key=k;
		this.userName=userName; 
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	 public static SellerDTO toDTO(Seller seller) {
		    if (seller == null) {
		      return null;
		    }
		    SellerDTO sellerDTO = new SellerDTO(seller.getUserName(),seller.getPassword());
		    sellerDTO.setFirstName(seller.getFirstName());
		    sellerDTO.setLastName(seller.getLastName());
		    sellerDTO.setTelephone(seller.getTelephone());
		    sellerDTO.setCity(seller.getCity());
		    sellerDTO.setZipCode(seller.getZipCode());
		    sellerDTO.setAddress(seller.getAddress());
		    sellerDTO.setSerialDevice(seller.getSerialDevice());
		    return sellerDTO;
	}

	public String getSerialDevice() {
		return serialDevice;
	}

	public void setSerialDevice(String serialDevice) {
		this.serialDevice = serialDevice;
	}

	public UserAccount getUserA() {
		return userA;
	}

	public Key getKey() {
		return key;
	}

	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public String getTelephone() {
		return telephone;
	}

	public void setTelephone(String telephone) {
		this.telephone = telephone;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public void setVersionCustomer(Long versionCustomer) {
		this.versionCustomer = versionCustomer;
	}

	public Long getVersionCustomer() {
		return versionCustomer;
	}

	public void setVersionProduct(Long versionProduct) {
		this.versionProduct = versionProduct;
	}

	public Long getVersionProduct() {
		return versionProduct;
	}

	public void setCity(String city) {
		this.city = city;
	}

	public String getCity() {
		return city;
	}

	public String getZipCode() {
		return zipCode;
	}
	public void setZipCode(String zipCode) {
		this.zipCode = zipCode;
	}


}
